package com.xubeihong.xubeihong;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.concurrent.ExecutionException;

@Slf4j
@Component
public class PutCaffeineSchedual {

    @Autowired
    private CacheManager cacheManager;

    @Scheduled(cron = "20 54 9 * * ?")
    //@Scheduled(cron = "59 13 23 * * ?")
    public int getTicket() throws ExecutionException, InterruptedException {
        //System.out.println(new Date()+"执行");
        cacheManager.getCache("ticket").put("num", 5);
        return 0;
    }

}
